// 接口的实现
interface ISWim {
    swimming: () => void
}

interface IEat {
    eating: () => void
}

// 用类实现接口
class Animal {

}

//继承：只能实现单继承
//实现：类可以实现多个接口
class Fish extends Animal implements ISWim, IEat {
    swimming() {
        console.log();
    }
    eating() {
        console.log();
        
    }
}


class Person implements ISWim {
    swimming () {
        console.log('person');
    }
}

// 编写公共API：面向接口编程
function swimAction(swimable: ISWim) {
    swimable.swimming()
}
swimAction(new Fish())
swimAction(new Person())